package com.mall.commons.tool.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * Author  kkw
 * Date  2021/6/23 20:05
 * Version 1.0
 * Description :
 */
public class GetUserInfoUtil {
    public static Long getUid(HttpServletRequest request) {
        String userInfo = ((String) request.getAttribute("userInfo"));
        Map<String,String> map = JSON.parseObject(userInfo, Map.class);
        Long uid = Long.valueOf(map.get("uid"));
        return uid;
    }

    public static String getUserName(HttpServletRequest request) {
        String userInfo = ((String) request.getAttribute("userInfo"));
        Map<String,String> map = JSON.parseObject(userInfo, Map.class);
        String username = map.get("username");
        return username;
    }
}
